package com.salelogistics.system.api.factory;

import com.salelogistics.common.core.web.domain.AjaxResult;
import com.salelogistics.common.core.web.page.TableDataInfo;
import com.salelogistics.system.api.RemoteBasLotService;
import com.salelogistics.system.api.RemoteBasMaterialService;
import com.salelogistics.system.api.domain.BasLot;
import com.salelogistics.system.api.domain.BasMaterial;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

public class RemoteBasMaterialFallBackFactory implements FallbackFactory<RemoteBasMaterialService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteBasMaterialService.class);

    @Override
    public RemoteBasMaterialService create(Throwable throwable) {
        log.error("服务调用失败:{}", throwable.getMessage());
        return new RemoteBasMaterialService() {

            @Override
            public AjaxResult selectBasMaterialByMaterialId(Long materialId) {
                return AjaxResult.error("查询失败-"+throwable.getMessage());
            }

            @Override
            public TableDataInfo selectBasMaterialList(BasMaterial basMaterial) {
                TableDataInfo tableDataInfo=new TableDataInfo();
                tableDataInfo.setMsg("查询失败-"+throwable.getMessage());
                return tableDataInfo;
            }
        };
    }
}
